package com.liang.springbatch.itemreader;

import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;

import java.util.Iterator;
import java.util.List;

/**
 * @ClassName MyReader
 * @Description TODO
 * @Author liang
 * @Date 2019/7/1 16:01
 * @Version 1.0
 **/
public class MyReader implements ItemReader<String> {
    private Iterator<String> iterator;

    public MyReader(List<String> list){
        iterator = list.iterator();
    }
    @Override
    public String read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
        //一个个的读取数据
        if(iterator.hasNext()){
            return this.iterator.next();
        }else {
            return null;
        }
    }
}
